import Home from '@/components/layout/Home'
import Index from '@/components/views/Index'
import store from "@/store"

let login = resolve => require(['@/components/pages/Login'], resolve)
let index = resolve => require(['@/components/views/Index'], resolve)
// const login = () => import('@/components/pages/Login')
let NotFound = () => import('@/components/pages/NotFound')
let userInfo = resolve => require(['@/components/views/Userinfo'], resolve)
let E404 = () => import('@/components/pages/E404')
let vod = resolve => require(['@/views/sys/vod.vue'], resolve)
let livevideo = resolve => require(['@/views/sys/livevideo.vue'], resolve)
let main = resolve => require(['@/views/sys/hello'], resolve)
let history = resolve => require(['@/views/sys/history'], resolve)
let notFound = resolve => require(['@/views/404'], resolve)
let organizationManage = resolve => require(['@/views/sys/organizationManage'], resolve)
let userManage = resolve => require(['@/views/sys/userManage'], resolve)
let role = resolve => require(['@/views/sys/role'], resolve)
let resource = resolve => require(['@/views/sys/resource'], resolve)
let logs = resolve => require(['@/views/sys/logs'], resolve)
let statisticsUser = resolve => require(['@/views/sys/statisticsUser'], resolve)
let statisticsVideo = resolve => require(['@/views/sys/statisticsVideo'], resolve)
let statisticsLive = resolve => require(['@/views/sys/statisticsLive'], resolve)
let statisticsOrg = resolve => require(['@/views/sys/statisticsOrg'], resolve)
let statisticsStore = resolve => require(['@/views/sys/statisticsStore'], resolve)
let bulletin = resolve => require(['@/views/sys/bulletin'], resolve)
let userM = resolve => require(['@/views/sys/userM'], resolve)
let dept = resolve => require(['@/views/sys/dept'], resolve)
let liveManage = resolve => require(['@/views/sys/liveManage'], resolve)
let vodManage = resolve => require(['@/views/sys/vodManage'], resolve)
let echarts = resolve => require(['@/views/echarts'], resolve)
let flowchat = resolve => require(['@/views/sys/flowchat'], resolve)
let flowInst = resolve => require(['@/components/flowchat/flowInst'], resolve)
let flow = resolve => require(['@/views/sys/flow'], resolve)
let assetbuy = resolve => require(['@/views/busy/assetbuy'], resolve)
let routes = [
  {
    path: '/login',
    name: 'login',
    component: login,
    hidden: true,
    beforeEnter: (to, from, next) => {
      // console.log(store.state)
      if (store.state.app.isLogin) {
        next('/index')
      } else {
        next()
      }
    }
  },
  {
    path: '/',
    component: Home,
    name: 'Home',
    iconCls: 'stats-bars',
    redirect: { path: '/index' },
    children: [
      { path: '/index', component: index, name: '首页', hidden: true },
      { path: '/userInfo', component: userInfo, name: '用户信息', hidden: true },
      { path: '/main', component: echarts, name: '主页', hidden: true },
      { path: '/vod', component: vod, name: '点播频道' },
      { path: '/livevideo', component: livevideo, name: '直播频道' },
      { path: '/history', component: history, name: '观看历史' },

      { path: '/organizationManage', component: organizationManage, name: '单位管理' },
      { path: '/userManage', component: userManage, name: '用户管理' },
      { path: '/role', component: role, name: '角色管理' },
      { path: '/resource', component: resource, name: '资源管理' },
      { path: '/logs', component: logs, name: '操作日志' },
      { path: '/flowchat', component: flowchat, name: 'flowchat' },
      { path: '/flowInst', component: flowInst, name: 'flowInst' },

      { path: '/flow', component: flow, name: '流程管理' },
      // {path: '/dashboard', component: dashboard, name: '综合分析'},
      { path: '/statisticsStore', component: statisticsStore, name: '存储空间' },
      { path: '/statisticsOrg', component: statisticsOrg, name: '单位统计' },
      { path: '/statisticsUser', component: statisticsUser, name: '人员统计' },
      { path: '/statisticsVideo', component: statisticsVideo, name: '视频统计' },
      { path: '/statisticsLive', component: statisticsLive, name: '直播统计' },

      { path: '/bulletin', component: bulletin, name: '公告管理' },
      { path: '/userM', component: userM, name: '人员管理' },
      { path: '/dept', component: dept, name: '部门管理' },
      { path: '/liveManage', component: liveManage, name: '直播频道管理' },
      { path: '/vodManage', component: vodManage, name: '点播资源管理' },

      { path: '/assetbuy', component: assetbuy, name: '采购单' },
    ]
  },
  {
    path: '/error404',
    name: 'error404',
    component: E404
  },
  {
    path: '*',
    redirect: '/notFound'
  },
  {
    path: '/404',
    component: notFound,
    name: '',
    hidden: true
  }
]

export default routes




